
#region Using directives

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;

#endregion
/** 
COPYRIGHT (C) 2008 Piyusha Desai. All Rights Reserved.
* Read Licence.txt before using this application.
*/

namespace SmsBuddy
{
    
// All group name here.
  
    public class QuestionDialog : System.Windows.Forms.Form
    {
        public enum AnswerType
        {
            Text,
            MultipleChoice,
        }

        private TextBox txtAnswer;
        private MenuItem mnuOk;
        private MenuItem mnuCancel;

        private Label lblQuestion;

        string question;
        public string Question
        {
            get { return question; }
            set { question = value; }
        }

        string answer;
        private ComboBox cmbAnswer;
    
        public string Answer
        {
            get { return answer; }
            set { answer = value; }
        }

        string[] choices;

        public string[] Choices
        {
            get { return choices; }
            set { choices = value; }
        }

        AnswerType type = AnswerType.Text;

        public AnswerType Type
        {
            get { return type; }
            set { type = value; }
        }



        private System.Windows.Forms.MainMenu mainMenu1;

        public QuestionDialog()
        {
            InitializeComponent();
        }



     
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code


        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
      
        private void InitializeComponent()
        {
            this.mainMenu1 = new System.Windows.Forms.MainMenu();
            this.mnuOk = new System.Windows.Forms.MenuItem();
            this.mnuCancel = new System.Windows.Forms.MenuItem();
            this.txtAnswer = new System.Windows.Forms.TextBox();
            this.lblQuestion = new System.Windows.Forms.Label();
            this.cmbAnswer = new System.Windows.Forms.ComboBox();
            this.SuspendLayout();
            // 
            // mainMenu1
            // 
            this.mainMenu1.MenuItems.Add(this.mnuOk);
            this.mainMenu1.MenuItems.Add(this.mnuCancel);
            // 
            // mnuOk
            // 
            this.mnuOk.Text = "Ok";
            this.mnuOk.Click += new System.EventHandler(this.mnuOk_Click);
            // 
            // mnuCancel
            // 
            this.mnuCancel.Text = "Cancel";
            this.mnuCancel.Click += new System.EventHandler(this.mnuCancel_Click);
            // 
            // txtAnswer
            // 
            this.txtAnswer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtAnswer.Location = new System.Drawing.Point(3, 73);
            this.txtAnswer.Name = "txtAnswer";
            this.txtAnswer.Size = new System.Drawing.Size(234, 30);
            this.txtAnswer.TabIndex = 1;
            // 
            // lblQuestion
            // 
            this.lblQuestion.Dock = System.Windows.Forms.DockStyle.Top;
            this.lblQuestion.Location = new System.Drawing.Point(0, 0);
            this.lblQuestion.Name = "lblQuestion";
            this.lblQuestion.Size = new System.Drawing.Size(240, 70);
            this.lblQuestion.Text = "Enter a name for your group:";
            // 
            // cmbAnswer
            // 
            this.cmbAnswer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.cmbAnswer.Location = new System.Drawing.Point(12, 73);
            this.cmbAnswer.Name = "cmbAnswer";
            this.cmbAnswer.Size = new System.Drawing.Size(216, 30);
            this.cmbAnswer.TabIndex = 2;
            this.cmbAnswer.Visible = false;
            // 
            // QuestionDialog
            // 
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
            this.ClientSize = new System.Drawing.Size(240, 266);
            this.Controls.Add(this.cmbAnswer);
            this.Controls.Add(this.lblQuestion);
            this.Controls.Add(this.txtAnswer);
            this.Menu = this.mainMenu1;
            this.Name = "QuestionDialog";
            this.Text = "Group Name";
            this.Load += new System.EventHandler(this.GroupName_Load);
            this.ResumeLayout(false);

        }

        #endregion

        private void mnuOk_Click(object sender, EventArgs e)
        {
            switch (Type)
            {
                case AnswerType.Text:
                    Answer = txtAnswer.Text;
                    break;
                case AnswerType.MultipleChoice:
                    if (cmbAnswer.SelectedValue != null)
                    {
                        Answer = cmbAnswer.SelectedValue.ToString();
                    }
                    break;
            }
            DialogResult = DialogResult.OK;
            Close();
        }

        private void mnuCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void GroupName_Load(object sender, EventArgs e)
        {
            txtAnswer.Text = Answer;
            lblQuestion.Text = Question;

            if (choices != null)
            {
                foreach (string choice in choices)
                {
                    cmbAnswer.Items.Add(choice);
                }
            }
        }
    }
}
